package com.leifeng.demo.core;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * @ClassName MyHttpSessionListener
 * @Author leimingfeng
 * @Date 2019/3/1 10:04
 * @Description TODO
 * @Version 1.0
 **/
public class MyHttpSessionListener implements HttpSessionListener {

    private int numberCount = -1;

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        numberCount++;
        se.getSession().getServletContext().setAttribute("numberCount",numberCount);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        numberCount--;
        se.getSession().getServletContext().setAttribute("numberCount",numberCount);
    }
}
